package com.example.demo_yunpan.service;

import com.example.demo_yunpan.entity.file;
import com.example.demo_yunpan.entity.folder;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public interface HdfsFileService {


    /*
    * 获取当前路径下的所有文件
    * @param path
    * @return
    * */
    public List<String> getFileList(String path) throws IOException;

    /**
     * 上传文件
     * @param file
     * @param folderName
     * @param userId
     * @return
     */

    public ResponseEntity<String> uploadFile(MultipartFile file, String folderName, int userId, String hdfsPath);



    /**
     * 下载文件到本地
     * @param fileId
     * @param localFilePath
     * @return
     * */
    public void downloadFile(int fileId, String localFilePath) throws IOException;

    /**
     * 根据文件ID获取文件名
     * @param FileId
     * @return fileName
     * @throws IOException
     */
    public String getFileName(int FileId) throws IOException;

    /**
    * 重命名文件
    * @param oldName
    * @param newName
    * @param currentPath
    * @return
    * */
    public boolean reNameFile(String oldName,String newName,String currentPath) throws IOException;

    /**
    * 删除文件
    * @param fileName
    * @param currentPath
    * @return
    * */
    public boolean delFile(String fileName,String currentPath) throws IOException;

    /**
    * 创建文件
    * @param newName
    * @param currentPath
    * @return
    * */
    public boolean createFile(String newName,String currentPath) throws IOException;

    /*
    * 移动文件
    * @param oldPath
    * @param newPath
    * @param currentPath
    * @return
    * */
    public boolean moveTo(String oldName,String newPath,String currentPath) throws IOException;

    /*
    * @param currentPath
    * @param type
    * @param map
    * @return
    * */
    public List<file> selectfile(String currentPath, String type, Map<String, Set<String>> map) throws IOException;

    /*
    * 查询文件是否已经存在
    * @param path
    * @return
    * */
    public boolean fileExist(String path) throws IOException;

    /**
     * 根据用户ID以及目录查询文件
     * @param userId,path
     * return 文件列表
     * */
    public List<file> findFileByUserId(String userId,String path);

    /**
     * 查询同一个用户Id的所有文件夹
     * @param userId,fileNameFuzzy,category
     * return List
     * */
    List<file> findAllByuserId(String userId, String fileNameFuzzy, String category);
    /**
     * 文件重名校验
     * @param fileName
     * @param folderName
     * @return
     */
    public String checkAndRenameFileName(String fileName, String folderName);
}
